import api from '../../../fetch/api'

export default {
  data() {
    return {
      otherDetailVisible:false,
      otherDetail:[
        {
          typeName: '',
          realValue:'',
          realChargeNum: '',
        }
      ]
    }
  },
  created() {
    
  },
  methods: {
    // 查看支付来源其他
    checkOtherList(rowData){
      if(Array.isArray(rowData.otherList) && rowData.otherList.length){
        this.otherDetail = []
        rowData.otherList.forEach(elem=>{
          let tmpObj = {
            typeName: elem.typeName,
          }
          tmpObj.realValue = elem.realValue ? elem.realValue : ''
          tmpObj.realValue += elem.realChargeNum ? '('+elem.realChargeNum+')' : ''
          this.otherDetail.push(tmpObj)
        })
        this.otherDetailVisible = true
      }
    },
    // 导出明细
    exportDataDetail(rowData){
      let self = this
      let params = {}     
      if(self.searchList[0].value=='YEAR'){
        self.showToast('请选择日报或月报时间维度',0,2000);
        return;
      }else if(self.searchList[0].value=='MONTH'){ //月报
        let dateObj = moment(rowData.statDim)  
        params.query_payTimeFrom = dateObj.startOf('month').format("YYYY-MM-DD")+" 00:00:00"
        params.query_payTimeTo = dateObj.endOf('month').format("YYYY-MM-DD")+" 23:59:59"
      }else{ //日报
        params.query_payTimeFrom = moment(rowData.statDim).format("YYYY-MM-DD")+" 00:00:00"
        params.query_payTimeTo = moment(rowData.statDim).format("YYYY-MM-DD")+" 23:59:59"
      }
      params.parkIds = rowData.parkId
      self.showDialog("确认导出明细?", '', function () {
        self.toExportAsync('/report/tmp_charge/newExportDetail.do', params)
      })
    },
    // 重新生成按钮
    reBuild(){
      this.$refs.myReBuildBtn.reBuild()
    },
    getList() {
      if (!this.searchParams.query_chargeDateStart) {
        this.showToast('请选择时间区间');
        return false;
      }
      let params = $.extend({}, this.searchParams, this.otherParams);
      this.getItemList(params);
    },
    getItemList(aparams) { //查询列表
      let self = this,
        params = {
          page: this.pageNumber,
          rp: this.pageSize
        };
      params = $.extend({}, params, aparams);
      api.fetchGet('/report/tmp_charge/newPageList.do', params)
        .then(res => {
          let data = res.data,list = data.rows;
          self.tbodysInfo = [];
          for(let i = 0; i<list.length; i++){
            let obj = list[i];
            self.tbodysInfo.push(obj);
          }
          self.total = data.total;
        }, err => {})
    },
    exportData() {
      let self = this;
      let params = {};
      params = $.extend({}, params, this.searchParams, this.otherParams);
      self.showDialog("确认导出该报表?", '', function () {
        self.toExportAsync('report/tmp_charge/newExport.do', params)
      })
    },
  }
}
